from tests.rypark_background.get_cookie import *
from common.config import *
import requests


class ParkData:
    # 商户后台入场次数数据
    def shop_enter_data(self, env, timeStart, timeEnd, queryType=''):
        base_url = getconf(env, "rypark_url")
        url = base_url + "/easypark-backend/data/bsEnterTimesData"
        headers = {"content-type": "application/json;charset=UTF-8",
                   "cookie": shop_cookies(env)}
        dict = {"queryType": queryType,
                "timeStart": timeStart,
                "timeEnd": timeEnd}
        return requests.post(url, headers=headers, json=dict).json()

    # 商户后台首页数据
    def shop_main_data(self, env, startDate, endDate):
        base_url = getconf(env, "rypark_url")
        url = base_url + "/easypark-backend/data/bsMainData"
        headers = {"content-type": "application/json;charset=UTF-8",
                   "cookie": shop_cookies(env)}
        dict = {"startDate": startDate,
                "endDate": endDate}
        return requests.post(url, headers=headers, json=dict).json()

    # 运营后台查询车流量数据
    def internal_enter_data(self, env, startDate, endDate, parkId):
        base_url = getconf(env, "rypark_url")
        url = base_url + "/easypark-backend/data/mainFlowData"
        headers = {"content-type": "application/json;charset=UTF-8",
                   "cookie": internal_cookies(env)}
        dict = {"parkId": parkId,
                "startDate": startDate,
                "endDate": endDate}
        return requests.post(url, headers=headers, json=dict).json()

    # 运营后台查询支付数据
    def internal_main_pay_data(self, env, startDate, endDate):
        base_url = getconf(env, "rypark_url")
        url = base_url + "/easypark-backend/data/mainPayData"
        headers = {"content-type": "application/json;charset=UTF-8",
                   "cookie": internal_cookies(env)}
        dict = {"startDate": startDate,
                "endDate": endDate}
        return requests.post(url, headers=headers, json=dict).json()
